<?php
/*
 * Licensed this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

namespace org\boapi\finance;

  include_once (dirname(__FILE__) . '/Mathfunctions.php');

/**
 * Diners Club credit card
 * @author Sebastian Ritter
 * @version 1.0.0.0
 * @license Apache License Version 2.0
 */
final class DinersClub extends \org\boapi\finance\AbstractCreditCard {

	/**
	 * Is the checknumber correct?
	 * @return boolean
	 */
    public function isChecknumberCorrect () {
      $ok = false;
      if (\org\boapi\math\Mathfunctions::isLuhn ($this->getValue ())) {
        $firstAndSecond = substr ($this->getValue (),0, 2);
        $firstSecondAndThird = substr ($this->getValue (),0, 2);
        if ('300' == $firstSecondAndThird ||
            '301' == $firstSecondAndThird ||
            '302' == $firstSecondAndThird ||
            '303' == $firstSecondAndThird ||
            '304' == $firstSecondAndThird ||
            '305' == $firstSecondAndThird ||
            '36' == $firstAndSecond ||
            '38' == $firstAndSecond) {
          $ok = true;
        }
      }
      return ok;
    }

}
?>